(function($) { let gDocument = $(document), gProgressBarE = $('.gutentor-element-progressbar'), counter_element = $('.gutentor-element-counter'), gWindow = $(window), gBody = $('body'), gWindowWidth = gWindow.width(), gM11Init = false, gFlexInit = false; /*Gutentor gBooleanVal*/ function gBooleanVal(val) { if (typeof val === 'boolean') { return val; } return (val === 'true'); } function gSlick(gThis) { let gss = {}; /*Slick Setting*/ if (gThis[0].hasAttribute('data-dots')) { gss.dots = gBooleanVal(gThis.data('dots')); } if (gThis[0].hasAttribute('data-arrows')) { gss.arrows = gBooleanVal(gThis.data('arrows')); } if (gThis[0].hasAttribute('data-infinite')) { gss.infinite = gBooleanVal(gThis.data('infinite')); } if (gThis[0].hasAttribute('data-speed')) { gss.speed = parseInt(gThis.data('speed')); } if (gThis[0].hasAttribute('data-slideitemdesktop')) { gss.slidesToShow = parseInt(gThis.data('slideitemdesktop')); } if (gThis[0].hasAttribute('data-slidescroll-desktop')) { gss.slidesToScroll = parseInt(gThis.data('slidescroll-desktop')); } if (gThis[0].hasAttribute('data-nextarrow')) { gss.nextArrow = ''; } else { gss.nextArrow = ''; } if (gThis[0].hasAttribute('data-prevarrow')) { gss.prevArrow = ''; } else { gss.prevArrow = ''; } if (gThis[0].hasAttribute('data-autoplay')) { gss.autoplay = gBooleanVal(gThis.data('autoplay')); if (gThis[0].hasAttribute('data-autoplayspeed')) { gss.autoplaySpeed = parseInt(gThis.data('autoplayspeed')); } if (gThis[0].hasAttribute('data-pauseonfocus')) { gss.pauseOnFocus = gBooleanVal(gThis.data('pauseonfocus')); } if (gThis[0].hasAttribute('data-pauseonhover')) { gss.pauseOnHover = gBooleanVal(gThis.data('pauseonhover')); } } if (gThis[0].hasAttribute('data-draggable')) { gss.draggable = gBooleanVal(gThis.data('draggable')); } if (gThis[0].hasAttribute('data-fade')) { gss.fade = gBooleanVal(gThis.data('fade')); } if (gThis[0].hasAttribute('data-blockimagesliderfade')) { gss.fade = gBooleanVal(gThis.data('blockimagesliderfade')); } if (gThis[0].hasAttribute('data-cmondesktop')) { gss.centerMode = gBooleanVal(gThis.data('cmondesktop')); if(gBooleanVal(gThis.data('cmondesktop'))){ if (gThis[0].hasAttribute('data-cmpaddingdesktop')) { gss.centerPadding = gThis.data('cmpaddingdesktop'); } } } /*Responsive Setting*/ let rTgss = {}, rMgss = {}; if (gThis[0].hasAttribute('data-slideitemtablet')) { rTgss.slidesToShow = parseInt(gThis.data('slideitemtablet')); } if (gThis[0].hasAttribute('data-slidescroll-tablet')) { rTgss.slidesToScroll = parseInt(gThis.data('slidescroll-tablet')); } if (gThis[0].hasAttribute('data-dotstablet')) { rTgss.dots = gBooleanVal(gThis.data('dotstablet')); } if (gThis[0].hasAttribute('data-arrowstablet')) { rTgss.arrows = gBooleanVal(gThis.data('arrowstablet')); } if (gThis[0].hasAttribute('data-cmontablet')) { rTgss.centerMode = gBooleanVal(gThis.data('cmontablet')); if(gBooleanVal(gThis.data('cmontablet'))){ if (gThis[0].hasAttribute('data-cmpaddingtablet')) { rTgss.centerPadding = gThis.data('cmpaddingtablet'); } } } /*Responsive mobile*/ if (gThis[0].hasAttribute('data-slideitemmobile')) { rMgss.slidesToShow = parseInt(gThis.data('slideitemmobile')); } if (gThis[0].hasAttribute('data-slidescroll-mobile')) { rMgss.slidesToScroll = parseInt(gThis.data('slidescroll-mobile')); } if (gThis[0].hasAttribute('data-dotsmobile')) { rMgss.dots = gBooleanVal(gThis.data('dotsmobile')); } if (gThis[0].hasAttribute('data-arrowsmobile')) { rMgss.arrows = gBooleanVal(gThis.data('arrowsmobile')); } if (gThis[0].hasAttribute('data-cmonmobile')) { rMgss.centerMode = gBooleanVal(gThis.data('cmonmobile')); if(gBooleanVal(gThis.data('cmonmobile'))){ if (gThis[0].hasAttribute('data-cmpaddingmobile')) { rMgss.centerPadding = gThis.data('cmpaddingmobile'); } } } let rTSettings = { breakpoint: 1024, settings: rTgss }, rMSettings = { breakpoint: 480, settings: rMgss }; gss.responsive = []; gss.responsive.push(rTSettings); gss.responsive.push(rMSettings); /*Arrow Position*/ if (gThis[0].hasAttribute('data-arrowspositiondesktop') && 'gutentor-slick-a-default-desktop' !== gThis.data('arrowspositiondesktop')) { gss.appendArrows = gThis.siblings('.gutentor-slick-arrows'); } /*RTL*/ if (gBody.hasClass('rtl')) { gss.rtl = true; } /*Finally call Slick*/ if(gThis.hasClass('slick-initialized')) { gThis.slick('refresh') } else{ gThis.slick(gss); } } /*Magnific Popup * gThis * isI => is image * isG => is gallery * */ function gMagnificPopup(gThis, isI = false, isG = false) { let gma = {}; if (isI) { gma = { type: 'image', closeBtnInside: false, fixedContentPos: false }; } else { gma = { type: 'iframe', mainClass: 'mfp-fade', removalDelay: 160, preloader: false, fixedContentPos: false, }; } if (isG) { gma.gallery = { enabled: true, navigateByImgClick: true, preload: [0, 1] // Will preload 0 - before current, and 1 after the current image }; gma.callbacks = { elementParse: function(item) { if (item.el[0].getAttribute("data-media-type") === 'g-popup-video') { item.type = 'iframe'; } else { item.type = 'image'; } } } } gThis.magnificPopup(gma); } /*easyPieChart*/ function gEasyPieChart(gThis) { let gea = { barColor: gThis.data('barcolor'), trackColor: gThis.data('trackcolor'), scaleColor: gThis.data('scalecolor'), size: gThis.data('size'), lineCap: gThis.data('linecap'), animate: gThis.data('animate'), lineWidth: gThis.data('linewidth'), }; gThis.easyPieChart(gea); } /*CountUP*/ function gCountUp(gThis) { let startValue = parseInt(gThis.data('start')), endValue = parseInt(gThis.data('end')), duration = parseInt(gThis.data('duration')), nCountUp = new CountUp(gThis[0], startValue, endValue, 0, duration); nCountUp.start(); } function gIsEleInView(elem) { let docViewTop = $(window).scrollTop(), docViewBottom = docViewTop + $(window).height(), elemTop = $(elem).offset().top, elemBottom = elemTop + $(elem).height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); } function gTriggerCountUp(gThis){ if( gIsEleInView(gThis) ){ if( !gThis.hasClass('g-c-loaded')){ gThis.addClass('g-c-loaded') gCountUp(gThis) } } } function gTriggerPieChart(gThis){ if( gIsEleInView(gThis) ){ if( !gThis.hasClass('g-c-loaded')){ gThis.addClass('g-c-loaded') gEasyPieChart(gThis) } } } function gAddLoaded(gThis){ if( gIsEleInView(gThis) ){ if( !gThis.hasClass('g-c-loaded')){ gThis.addClass('g-c-loaded') gThis.css('width', gThis.attr("data-width") + "%"); } } } function gCountAndBar($wrap = null){ if( $wrap ){ /*CountUP Trigger*/ $wrap.find('.gutentor-single-item-number,.gutentor-counter-number-main').each(function() { gTriggerCountUp($(this)) }); /*easyPieChart Trigger*/ $wrap.find('.gutentor-progressbar-circular,.gutentor-element-progressbar-circular').each(function() { gTriggerPieChart($(this)) }); /*easyPieChart Trigger*/ $wrap.find('.gutentor-porgress-bar-item .progressbar,.gutentor-element-progressbar-box .gutentor-element-progressbar-horizontal').each(function() { gAddLoaded($(this)) }); } else{ /*CountUP Trigger*/ $('.gutentor-single-item-number,.gutentor-counter-number-main').each(function() { gTriggerCountUp($(this)) }); /*easyPieChart Trigger*/ $('.gutentor-progressbar-circular,.gutentor-element-progressbar-circular').each(function() { gTriggerPieChart($(this)) }); /*easyPieChart Trigger*/ $('.gutentor-porgress-bar-item .progressbar,.gutentor-element-progressbar-box .gutentor-element-progressbar-horizontal').each(function() { gAddLoaded($(this)) }); } } gCountAndBar() $(window).scroll( function(){ gCountAndBar() }); /*Count Down*/ function gCountDown(gThis) { // Set the date we're counting down to let gutentor_event_date = gThis.data('eventdate'); if (gutentor_event_date === undefined || gutentor_event_date === null) { gThis.html("Please set validate Date and time for countdown "); return false; } let expired_text = gThis.data('expiredtext'), gutentor_day = gThis.find('.day'), gutentor_hour = gThis.find('.hour'), gutentor_min = gThis.find('.min'), gutentor_sec = gThis.find('.sec'), gutentor_date_time = gutentor_event_date.split('T'); if (gutentor_date_time.length !== 2) { return false; } let date_collection = gutentor_date_time[0], time_collection = gutentor_date_time[1], date_explode = date_collection.split('-'); if (date_explode.length !== 3) { return false; } let time_explode = time_collection.split(':'); if (time_explode.length !== 3) { return false; } let gutentor_year_value = parseInt(date_explode[0]), gutentor_month_value = parseInt(date_explode[1]) - 1, gutentor_day_value = parseInt(date_explode[2]), gutentor_hour_value = parseInt(time_explode[0]), gutentor_minutes_value = parseInt(time_explode[1]), gutentor_second_value = parseInt(time_explode[2]), countDownDate = new Date(gutentor_year_value, gutentor_month_value, gutentor_day_value, gutentor_hour_value, gutentor_minutes_value, gutentor_second_value, 0).getTime(); // Update the count down every 1 second let x = setInterval(function() { // Get todays date and time let now = new Date().getTime(); // Find the distance between now an the count down date let distance = countDownDate - now; // Time calculations for days, hours, minutes and seconds let days = Math.floor(distance / (1000 * 60 * 60 * 24)); let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); let seconds = Math.floor((distance % (1000 * 60)) / 1000); // Display the result in the element gutentor_day.html(days); gutentor_hour.html(hours); gutentor_min.html(minutes); gutentor_sec.html(seconds); // If the count down is finished, write some text if (distance < 0) { clearInterval(x); gThis.html("" + expired_text + ""); } }, 1000); } /*Tabs*/ function gTabs() { gDocument.on('click', '.gutentor-tabs-list', function() { let thisTabInside = $(this), gutentorSingleItemIndex = thisTabInside.data('index'), gTabsC = thisTabInside.closest('.gutentor-tabs'), gTabsContentWrap = gTabsC.next('.gutentor-tabs-content-wrap'), gTabsSingleContent = gTabsContentWrap.find('.' + gutentorSingleItemIndex); gTabsSingleContent.siblings().removeClass('gutentor-tab-content-active'); thisTabInside.siblings().removeClass('gutentor-tab-active'); gTabsSingleContent.addClass('gutentor-tab-content-active'); thisTabInside.addClass('gutentor-tab-active'); }); } /*show more block*/ function gShowMoreBlock(className) { gDocument.on('click', className, function(e) { e.preventDefault(); if (className === '.gutentor-show-more-button') { $(this).closest('.gutentor-single-item-content').addClass('show-more-content'); } else if(className === '.gutentor-show-less-action-button') { $(this).closest('.gutentor-single-item-content').removeClass('show-more-content'); } else if(className === '.gutentor-adv-s-m-btn'){ $(this).closest('.g-m-advance-show-more').addClass('g-show-more-content'); } else if(className === '.gutentor-adv-s-l-btn'){ $(this).closest('.g-m-advance-show-more').removeClass('g-show-more-content'); } }); } /*API*/ function gP4GetLoader(type) { let gP4Loader; switch (type) { case 'gp4-animation-1': gP4Loader = '
'; break; case 'gp4-animation-2': gP4Loader = '
'; break; case 'gp4-animation-3': gP4Loader = '
'; break; case 'gp4-animation-4': gP4Loader = '
'; break; case 'gp4-animation-5': gP4Loader = '
'; break; default: gP4Loader = ''; break; } return gP4Loader; } function gApi(gAB, gParam, gAppend = false) { gParam.innerBlockType = gAB.data('i-b'); gParam.blockId = gAB.find('.gutentor-post-module').data('gbid'); gParam.postId = gAB.data('gpid'); /*Globally Add Tax and Term Data*/ if (gAB.find('.gutentor-filter-navigation').length) { gParam.gTax = gAB.find('.gutentor-filter-navigation').data('gtax'); gParam.gTerm = gAB.find('.gutentor-filter-item-active').children().attr('data-gterm'); if( 'gAll' === gParam.gTerm ){ gParam.allOpt = gAB.find('.gutentor-filter-item-active').children().attr('data-all-opt'); } } else { gParam.gTax = 'default'; gParam.gTerm = 'default'; } if (!gParam.paged) { gParam.paged = 1; } /*Search Field*/ if (gAB.find('.g-fm-search').length){ gParam.s = gAB.find('.g-fm-search').val(); } $.ajax({ type: 'GET', url: gutentorLS.restUrl + 'gutentor-self-api/v1/gadvancedb', data: gParam, beforeSend: function(xhr) { gAB.addClass(gAB.data('l-ani')); xhr.setRequestHeader('X-WP-Nonce', gutentorLS.restNonce); gAB.removeClass('gutentor-loaded'); gAB.find('.gutentor-post-module .grid-container').append(gP4GetLoader(gAB.data('l-ani'))); }, }).done(function(data) { if (!gAppend) { gAB.find('.gutentor-post-module').replaceWith(data.pBlog); } else { gAB.find('.gutentor-post-module .grid-container .grid-row').append($(data.pBlog).find('.grid-container .grid-row').html()); } gAB.find('.gutentor-pagination') .children() //Select all the children of the parent .not(':first-child') //Unselect the first child .not(':last-child') //Unselect the last child .remove(); let paged = parseInt(gParam.paged), max_num_pages = parseInt(data.max_num_pages); gAB.find('.gutentor-pagination').children('.gutentor-pagination-prev') .after(data.pagination) .children().attr('data-gpage', paged > 1 ? paged - 1 : 1); gAB.attr('data-maxnumpages', max_num_pages); gAB.find('.gutentor-pagination').children('.gutentor-pagination-next') .children().attr('data-gpage', max_num_pages > paged ? paged + 1 : max_num_pages); /*disabled class*/ if (paged <= 1) { gAB.find('.gutentor-pagination').children('.gutentor-pagination-prev').children().addClass('gutentor-disabled'); gAB.find('.gutentor-navigation').find('.g-nav-prev').addClass('gutentor-disabled'); } else { gAB.find('.gutentor-pagination').children('.gutentor-pagination-prev').children().removeClass('gutentor-disabled'); gAB.find('.gutentor-navigation').find('.g-nav-prev').removeClass('gutentor-disabled'); } if (max_num_pages <= paged) { gAB.find('.gutentor-pagination').children('.gutentor-pagination-next').children().addClass('gutentor-disabled'); gAB.find('.gutentor-navigation').find('.g-nav-next').addClass('gutentor-disabled'); /*for load more disabled class*/ gAB.find('.gutentor-post-footer.g-ap-load-more-template a.gutentor-button').addClass('gutentor-disabled'); } else { gAB.find('.gutentor-pagination').children('.gutentor-pagination-next').children().removeClass('gutentor-disabled'); gAB.find('.gutentor-navigation').find('.g-nav-next').removeClass('gutentor-disabled'); /*for load more disabled class*/ gAB.find('.gutentor-post-footer.g-ap-load-more-template a.gutentor-button').removeClass('gutentor-disabled'); } gAB.find('.gutentor-post-module').each(function() { gReloadMasonry($(this)); }); }).fail(function(jqXHR, textStatus, errorThrown) { console.log(jqXHR + " :: " + textStatus + " :: " + errorThrown); }).always(function() { $('.g-edd-cart .edd-no-js').hide(); $('.g-edd-cart .edd-add-to-cart').addClass('edd-has-js'); gAB.removeClass(gAB.data('l-ani')); gAB.addClass('gutentor-loaded'); gAB.find('.gutentor-post-module .grid-container').find('.gutentor-loading-wrap').remove(); }); } /*Filter Cats*/ gDocument.on('click', '.gutentor-filter-navigation .gutentor-filter-item>a', function(e) { e.preventDefault(); let gThis = $(this), gList = gThis.closest('.gutentor-filter-list'), gAB = gThis.closest('.gutentor-advanced-post-module'); if (gThis.parent().hasClass('gutentor-filter-item-active')) { return false; } gList.find('.gutentor-filter-item').removeClass('gutentor-filter-item-active'); gThis.parent().addClass('gutentor-filter-item-active'); /*for load more reset pagination */ gAB.find('.gutentor-post-footer.g-ap-load-more-template a.gutentor-button').removeAttr('data-gpage'); /*Search reset*/ if (gAB.find('.g-fm-search').length){ gAB.find('.g-fm-search').val(''); } gApi( gAB, {} ) }); /*Numeric Pagination*/ gDocument.on('click', '.gutentor-pagination a', function(e) { e.preventDefault(); let gThis = $(this), gAB = gThis.closest('.gutentor-advanced-post-module'); if (gThis.hasClass('gutentor-disabled')) { return false; } if (gThis.parent().hasClass('gutentor-pagination-active')) { return false; } let currentPage = gThis.parent().siblings('.gutentor-pagination-active').children().attr('data-gpage'); if (currentPage == gThis.attr('data-gpage')) { return false; } let gParam = { paged: gThis.attr('data-gpage'), }; if (parseInt(gAB.attr('data-maxnumpages')) < parseInt(gParam.paged)) { return false; } gApi( gAB, gParam ) }); /*Navigation*/ gDocument.on('click', '.gutentor-navigation a', function(e) { e.preventDefault(); let gThis = $(this), gNav = gThis.closest('.gutentor-navigation'), gAB = gThis.closest('.gutentor-advanced-post-module'); if (gThis.hasClass('gutentor-disabled')) { return false; } let current_page = parseInt(gNav.attr('data-gpage')), nextPage; if (gThis.hasClass('g-nav-prev')) { nextPage = current_page - 1; } else { nextPage = current_page + 1; } let gParam = { paged: nextPage }; gNav.attr('data-gpage', nextPage); gApi( gAB, gParam ) }); /*Load More*/ gDocument.on('click', '.gutentor-post-footer.g-ap-load-more-template a.gutentor-button', function(e) { e.preventDefault(); let gThis = $(this), gAB = gThis.closest('.gutentor-advanced-post-module'); if (gThis.hasClass('gutentor-disabled')) { return false; } if (!gThis.attr('data-gpage')) { gThis.attr('data-gpage', 2); } let gParam = { paged: gThis.attr('data-gpage') }; gThis.attr('data-gpage', parseInt(gThis.attr('data-gpage')) + 1) gApi( gAB, gParam, true ) }); /*Search Icon*/ gDocument.on('click', '.g-search-icon', function(e) { e.preventDefault(); let gThis = $(this), gAB = gThis.closest('.gutentor-advanced-post-module'); /*commented on request of a user*/ /*https://wordpress.org/support/topic/post-module-header-search-keywords/#post-15077989*/ /* if( !gAB.find('.g-fm-search').val()){ return false; }*/ gApi( gAB, {} ) }); /*Search Enter*/ $( document ).on( 'keydown', '.gutentor-advanced-post-module .g-fm-search', function(e){ let key = e.which; if (key === 13) { e.preventDefault(); let gThis = $(this), gAB = gThis.closest('.gutentor-advanced-post-module'); /*commented on request of a user*/ /*https://wordpress.org/support/topic/post-module-header-search-keywords/#post-15077989*/ /* if( !gAB.find('.g-fm-search').val()){ return false; }*/ gApi( gAB, {} ) } } ); /*Advanced popup*/ function gAdvPopupOpen(gma,gThis){ if( gThis.attr('devices')){ let devices = JSON.parse(gThis.attr('devices')); if( Array.isArray(devices)){ if( devices.includes('desktop') && window.screen.width > 991){ $.magnificPopup.open(gma); } else if( devices.includes('mobile') && window.screen.width < 768){ $.magnificPopup.open(gma); } else if( devices.includes('tablet') && window.screen.width >= 767 && window.screen.width <= 991){ $.magnificPopup.open(gma); } } } else{ $.magnificPopup.open(gma); } } let gIdleTime; function gSetIdleTime(gma,gThis) { window.onload = resetTimer; window.onmousemove = resetTimer; window.onmousedown = resetTimer; // catches touchscreen presses as well window.ontouchstart = resetTimer; // catches touchscreen swipes as well window.ontouchmove = resetTimer; // required by some devices window.onclick = resetTimer; // catches touchpad clicks as well window.onkeydown = resetTimer; window.addEventListener('scroll', resetTimer, true); // improved; see comments function resetTimer() { clearTimeout(gIdleTime); if( gThis.attr('timing')){ gIdleTime = setTimeout(function() { if( !gThis.attr('g-adv-popup-open')){ gAdvPopupOpen(gma,gThis); gThis.attr('g-adv-popup-open',true) } }, parseFloat(gThis.attr('timing'))*1000); } } } function gInitAdvPopup(){ function gIsTrue(val){ if(val && val == '1'){ return true; } return false; } let gma = {}, gIndex = {}, gCss = {}, sideCss = ''; $('.g-adv-popup').each(function(i) { let gThis = $(this), gMainClass = 'g-adv-popup-mfp '; gIndex[i] = {}; gma[i] = {}; gCss[i] = '.gadvpopupwow{visibility:hidden;}'; if( gThis.attr('closeBtnCol') ){ gCss[i] += '.'+gThis.attr('id')+'-mfp'+' .mfp-close{color:'+gThis.attr('closeBtnCol')+';}'; } if( gThis.attr('bgCol') || gThis.attr('bgGradient')){ let bgType = gThis.attr('bgType') ? gThis.attr('bgType') : '', bgcolor = bgType === 'solid' && gThis.attr('bgCol') ? gThis.attr('bgCol') : '', bgGradient = bgType === 'gradient' && gThis.attr('bgGradient') ? gThis.attr('bgGradient') : '', bgGradient2 = bgType === 'solid' && bgcolor ? 'none' : '', bgcolor2 = bgType === 'gradient' && gThis.attr('bgGradient') ? 'transparent' : ''; gCss[i] += '.gutentor-active .mfp-bg{'+GutentorGenerateCSS('background-color',bgcolor)+GutentorGenerateCSS('background-image',bgGradient2)+GutentorGenerateCSS('background-image',bgGradient)+GutentorGenerateCSS('background-color',bgcolor2)+'}'; } gMainClass += gThis.attr('id')+'-mfp '; gma[i] = { type: 'inline', items: { src: '#'+gThis.attr('id') }, }; if( gThis.attr('type')){ gMainClass += 'g-adv-popup-'+gThis.attr('type')+' '; if( 'modal' === gThis.attr('wval') ){ gma[i].modal = true; } if( 'modal' === gThis.attr('type')){ if( gThis.attr('wval') && gThis.attr('wunit') ){ gCss[i] += '.'+gThis.attr('id')+'-mfp'+' .mfp-container .mfp-content{width:'+gThis.attr('wval')+gThis.attr('wunit')+';}'; } } if( 'side' === gThis.attr('type') && gThis.attr('side')){ if( (gThis.attr('x') || gThis.attr('y')) && gThis.attr('sideunit') ){ if('top-left' === gThis.attr('side')){ sideCss += 'left:'+gThis.attr('x')+gThis.attr('sideunit')+' !important;'; sideCss += 'top:'+gThis.attr('y')+gThis.attr('sideunit')+' !important;'; } else if('top-right' === gThis.attr('side')){ sideCss += 'right:'+gThis.attr('x')+gThis.attr('sideunit')+' !important;'; sideCss += 'top:'+gThis.attr('y')+gThis.attr('sideunit')+' !important;'; } else if('bottom-left' === gThis.attr('side')){ sideCss += 'left:'+gThis.attr('x')+gThis.attr('sideunit')+' !important;'; sideCss += 'bottom:'+gThis.attr('y')+gThis.attr('sideunit')+' !important;'; } else if('bottom-right' === gThis.attr('side')){ sideCss += 'right:'+gThis.attr('x')+gThis.attr('sideunit')+' !important;'; sideCss += 'bottom:'+gThis.attr('y')+gThis.attr('sideunit')+' !important;'; } } if( gThis.attr('wval') && gThis.attr('wunit') ){ sideCss += 'width:'+gThis.attr('wval')+gThis.attr('wunit')+';'; } gCss[i] += '.'+gThis.attr('id')+'-mfp'+' {'+sideCss+'}'; gMainClass += 'g-adv-popup-side-'+gThis.attr('side')+' '; } } if( gMainClass){ gma[i].mainClass = gMainClass; } gma[i].closeOnBgClick = gIsTrue(gThis.attr('closeonbgclick')); gma[i].closeBtnInside = gIsTrue(gThis.attr('closebtninside')); gma[i].showCloseBtn = gIsTrue(gThis.attr('showclosebtn')); gma[i].enableEscapeKey = gIsTrue(gThis.attr('enableescapekey')); gma[i].fixedContentPos = gIsTrue(gThis.attr('fixedcontentpos')); gma[i].fixedBgPos = gIsTrue(gThis.attr('fixedbgpos')); if( !gma[i].closeBtnInside && $('body').hasClass('admin-bar')){ gCss[i] += '.'+gThis.attr('id')+'-mfp'+' {top:32px !important;}'; } gma[i].callbacks = { beforeOpen: function() { if(gCss[i]){ $("head").append(''); } if( gThis.attr('animation')){ this.st.mainClass = this.st.mainClass +' animated ' +gThis.attr('animation'); } }, open: function() { gRefreshJS($('.mfp-container')); /*WOW*/ if (typeof WOW !== 'undefined') { let wow = new WOW( { boxClass: 'gadvpopupwow' } ); wow.init(); } $('.mfp-bg').removeClass(this.st.mainClass); if( 'top' === gThis.attr('type') || 'bottom' === gThis.attr('type') || 'side' === gThis.attr('type')){ $('.mfp-bg').remove(); } }, close: function() { $('#gutentor-adv-popup-style').remove(); } }; if( gThis.attr('trigger')){ if( 'load' === gThis.attr('trigger') ){ if( gThis.attr('timing')){ setTimeout(function() { gAdvPopupOpen(gma[i],gThis); }, parseFloat(gThis.attr('timing'))*1000); } else{ gAdvPopupOpen(gma[i],gThis); } } else if( 'click' === gThis.attr('trigger') ){ gDocument.on('click', '.'+gThis.attr('clickclass'), function(e) { e.preventDefault(); gAdvPopupOpen(gma[i],gThis); }); } else if( 'idle' === gThis.attr('trigger') ){ gSetIdleTime(gma[i], gThis); } else if( 'scroll' === gThis.attr('trigger') ){ gIndex[i].lastScrollTop = 0; gIndex[i].open = false; gIndex[i].lastDirection = ''; gIndex[i].scrollDistance = $(window).scrollTop(); gIndex[i].triggerDistance = 0; if( gThis.attr('sval') ){ gIndex[i].triggerDistance = parseInt(gThis.attr('sval')); if( gThis.attr('sunit') && "%" === gThis.attr('sunit') ){ gIndex[i].triggerDistance = $(window).height()*gIndex[i].triggerDistance/100; } $(window).scroll(function(event){ if( !gIndex[i].open){ let st = $(this).scrollTop(); if (st > gIndex[i].lastScrollTop){ if( 'downscroll' !== gIndex[i].lastDirection){ gIndex[i].scrollDistance = gIndex[i].scrollDistance - (st - gIndex[i].lastScrollTop); } else{ gIndex[i].scrollDistance = gIndex[i].scrollDistance + (st - gIndex[i].lastScrollTop); } gIndex[i].lastDirection = 'downscroll'; if( 'top' === gThis.attr('direction') ){ if( gIndex[i].scrollDistance > gIndex[i].triggerDistance ){ gAdvPopupOpen(gma[i],gThis); gIndex[i].open = true; } } } else { if( 'upscroll' !== gIndex[i].lastDirection){ gIndex[i].scrollDistance = gIndex[i].scrollDistance - (st - gIndex[i].lastScrollTop); } else{ gIndex[i].scrollDistance = gIndex[i].scrollDistance + (gIndex[i].lastScrollTop - st); } gIndex[i].lastDirection = 'upscroll'; if( 'bottom' === gThis.attr('direction') ){ if( gIndex[i].scrollDistance > gIndex[i].triggerDistance ){ gAdvPopupOpen(gma[i],gThis); gIndex[i].open = true; } } } gIndex[i].lastScrollTop = st; } }); } } } }); } function gAdvPopupData() { let gAllScripts = [], gAllStyles = []; function getAllScripts(){ let scripts = window.document.getElementsByTagName('script'); $(scripts).each(function() { if( $(this).attr('src')){ gAllScripts.push($(this).attr('src')); } }); } getAllScripts(); function getAllStyles(){ let links = window.document.getElementsByTagName('link'); $(links).each(function() { if( $(this).attr('href')){ gAllStyles.push($(this).attr('href')); } }); } getAllStyles(); function filterContent(filterContent){ filterContent.find('script').each(function() { if( !gAllScripts.includes($(this).attr('src'))){ if( $(this).attr('src')){ $('head').append("